package com.example.factory.factory;

import com.example.factory.entity.Operation;
import com.example.factory.entity.OperationAdd;
import com.example.factory.entity.OperationSub;

/**
 * @version 1.0.0
 * @className: Factory
 * @description: 工厂类，根据传入的操作方法获取对应的对象。
 * @author: rosszhang
 * @date: 2022/5/12 21:15
 */
public class Factory {
    public static Operation createOperation(int oper) {
        Operation operation = null;
        if (oper == 1) {
            operation = new OperationAdd();
            return operation;
        } else if (oper == 2) {
            operation = new OperationSub();
            return operation;
        } else {
            operation = new Operation();
            return operation;
        }
    }
}
